package com.xp.interview.controller;

import com.xp.interview.service.InsertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by xp on 15/10/15.
 */

@Controller
public class InsertController {

    @Autowired
    private InsertService insertService;

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public String insertNote(@RequestParam(value = "title",required = true) String title,
                            @RequestParam(value = "content",required = true) String content)
    {

        insertService.insertNote(title,content);
        return "index";
    }
}
